VERSION 5.00
Begin VB.Form FrmElegir 
   BorderStyle     =   0  'None
   ClientHeight    =   8085
   ClientLeft      =   1815
   ClientTop       =   2535
   ClientWidth     =   11760
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   8085
   ScaleWidth      =   11760
   ShowInTaskbar   =   0   'False
   Begin VB.Timer Timer1 
      Interval        =   1
      Left            =   3480
      Top             =   3240
   End
   Begin VB.TextBox Text3 
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   3120
      TabIndex        =   7
      Top             =   1080
      Visible         =   0   'False
      Width           =   255
   End
   Begin VB.TextBox Text2 
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   645
      Left            =   4080
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   1
      Top             =   2760
      Width           =   7455
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   645
      Left            =   120
      MaxLength       =   20
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   0
      Top             =   2760
      Width           =   3495
   End
   Begin VB.Label SkinLabel2 
      Caption         =   "Observaciones"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   13.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Index           =   1
      Left            =   4200
      TabIndex        =   10
      Top             =   2400
      Width           =   4215
   End
   Begin VB.Label SkinLabel1 
      Caption         =   "Resultado"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   13.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Index           =   2
      Left            =   240
      TabIndex        =   9
      Top             =   2400
      Width           =   2775
   End
   Begin VB.Label Leyenda 
      Height          =   3300
      Left            =   240
      TabIndex        =   8
      Top             =   4560
      Width           =   11055
   End
   Begin VB.Label Label3 
      Height          =   615
      Left            =   6120
      TabIndex        =   5
      Top             =   240
      Visible         =   0   'False
      Width           =   2175
   End
   Begin VB.Label SkinLabel1 
      Height          =   255
      Index           =   0
      Left            =   720
      TabIndex        =   3
      Top             =   1920
      Width           =   1815
   End
   Begin VB.Label SkinLabel2 
      Height          =   255
      Index           =   0
      Left            =   4080
      TabIndex        =   4
      Top             =   1920
      Width           =   3615
   End
   Begin VB.Label SkinLabel1 
      Height          =   255
      Index           =   1
      Left            =   1560
      TabIndex        =   6
      Top             =   1680
      Width           =   255
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   0
      TabIndex        =   2
      Top             =   120
      Width           =   11535
   End
   Begin VB.Shape Shape1 
      BorderColor     =   &H00800000&
      BorderWidth     =   5
      Height          =   2175
      Left            =   0
      Top             =   1560
      Visible         =   0   'False
      Width           =   11655
   End
   Begin VB.Menu a121 
      Caption         =   "SHORT"
      Visible         =   0   'False
      Begin VB.Menu menumas2 
         Caption         =   "1"
         Shortcut        =   ^P
      End
      Begin VB.Menu menoss 
         Caption         =   "2"
         Shortcut        =   ^N
      End
      Begin VB.Menu Reactivo 
         Caption         =   "3"
         Shortcut        =   ^R
      End
      Begin VB.Menu NORECAT 
         Caption         =   "4"
         Shortcut        =   ^O
      End
   End
End
Attribute VB_Name = "FrmElegir"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public ob
Public res
Public Comodin
Public Opc
Public OPCION As Boolean
Public Texto As String
Dim Opciones(80)
Dim CualOpcion
Dim MaxOpcion
Sub Mostrar_Leyenda()
    Dim rs As DAO.Recordset
    Set rs = Base.OpenRecordset("select *from teclas where cod_examen=" & MdlFunciones.ObtenerCodigoexa(Label1.Caption))
    Leyenda.Caption = ""
    MaxOpcion = 0
    CualOpcion = 0
    While Not rs.EOF
        CualOpcion = 1
        MaxOpcion = MaxOpcion + 1
        Opciones(MaxOpcion) = rs(2)
        Leyenda.Caption = Leyenda.Caption & Chr(rs(1)) & "=>" & rs(2)
        rs.MoveNext
        If Not rs.EOF Then Leyenda.Caption = Leyenda.Caption & vbCrLf
    Wend
End Sub
Private Sub Form_Load()
    Timer1.Enabled = True
    Mostrar_Leyenda
    SkinLabel1(1).Caption = ""
    Text3.Visible = False
    
    

End Sub



Private Sub menoss_Click()
    Text1.Text = "NEGATIVO"
End Sub

Private Sub menumas2_Click()
    Text1.Text = "POSITIVO"
End Sub

Private Sub NORECAT_Click()
    Text1.Text = "NO REACTIVO"
End Sub

Private Sub Reactivo_Click()
    Text1.Text = "REACTIVO"
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
    Mostrar_Leyenda
    If OPCION Then
        KeyAscii = 0
        OPCION = False
        Text2.SetFocus
    End If
On Error GoTo pasar
    If KeyAscii = 13 Then
        KeyAscii = 0
        Text2.SetFocus
        Exit Sub
    End If
    If KeyAscii = 27 Then
        ob = ""
        res = "-"
        Comodin = ""
        Unload Me
    End If
   Exit Sub
pasar:
        ob = Text2.Text
        res = Text1.Text
        Comodin = Text3.Text
        
        Unload Me: ActGestor

End Sub

Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
    If Shift = 1 Then
        Dim rs As DAO.Recordset
        cod = Asc(UCase(Chr(KeyCode)))
        Set rs = Base.OpenRecordset("select *from teclas where cod_examen=" & MdlFunciones.ObtenerCodigoexa(Label1.Caption) & " and tecla=" & cod)
        If Not rs.EOF Then
            OPCION = True
            Text1.Text = rs(2)
        End If
    End If
    If KeyCode = 38 Then
        CualOpcion = CualOpcion - 1
        If CualOpcion < 0 Then CualOpcion = 0
        Text1.Text = Opciones(CualOpcion)
        If CualOpcion < 1 Then CualOpcion = MaxOpcion
    
    End If
    If KeyCode = 40 Then
        CualOpcion = CualOpcion + 1
        If CualOpcion > MaxOpcion Then CualOpcion = 1
        Text1.Text = Opciones(CualOpcion)
    End If
End Sub
Private Sub Text2_KeyUp(KeyCode As Integer, Shift As Integer)
    If Shift = 1 Then
        Dim rs As DAO.Recordset
        cod = Asc(UCase(Chr(KeyCode)))
        Set rs = Base.OpenRecordset("select *from teclas where cod_examen=" & MdlFunciones.ObtenerCodigoexa(Label1.Caption) & " and tecla=" & cod)
        If Not rs.EOF Then
            OPCION = True
            Text2.Text = rs(2)
        End If
    End If
    If KeyCode = 38 Then
        CualOpcion = CualOpcion - 1
        If CualOpcion < 0 Then CualOpcion = 0
        Text2.Text = Opciones(CualOpcion)
        If CualOpcion < 1 Then CualOpcion = MaxOpcion
    
    End If
    If KeyCode = 40 Then
        CualOpcion = CualOpcion + 1
        If CualOpcion > MaxOpcion Then CualOpcion = 1
        Text2.Text = Opciones(CualOpcion)
    End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        ob = Text2.Text
        res = Text1.Text
        Comodin = Text3.Text
        Unload Me: ActGestor
    End If
End Sub

Private Sub Timer1_Timer()
    Dim rs As DAO.Recordset
    Mostrar_Leyenda
    Timer1.Enabled = False
    Set rs = Base.OpenRecordset("select *from examenes where cod_examen=" & MdlFunciones.ObtenerCodigoexa(Label1.Caption))
    If Not rs.EOF Then
    If Not IsNull(rs("defecto")) And Text1.Text = "" Then Text1.Text = rs("defecto")
    End If
    Text1.SetFocus
    If Text1.Text = "*" Then
        ob = Text2.Text
        res = Text1.Text
        
        Comodin = Text3.Text
        Unload Me
    End If
    Dim v As New Pila
    Dim s As New Pila

    If Mid(Text1.Text, 1, 1) = "@" Then
        com = rs("defecto")
        formula = Mid(com, 2, Len(com)) + "|"
        v.Iniciar
        s.Iniciar
        Var = ""
        For i = 1 To Len(formula)
        
            l = Mid(formula, i, 1)
            If l = "|" Or l = "+" Or l = "-" Or l = "*" Or l = "/" Or l = ")" Or l = "(" Then
            If Not IsNumeric(Var) Then
            enc = False
            If Var = "" Then GoTo 1
                For j = 0 To FrmQuimica.List1.ListCount - 1
                    If Trim(FrmQuimica.List1.list(j)) = Trim(Var) Then
                        v.meter Val(FrmQuimica.List2.list(j))
                        enc = True
                        Exit For
                    End If
                Next
                If Not enc Then v.meter ("0")
                    
            Else
                v.meter Val(Var)
            End If
                Var = ""
1:
                
                If l = ")" Then
                    sim = ""
                    cont = 0
                    While sim <> "("
                        cont = cont + 1
                        a = v.remover
                        If v.Vacia Then cont = 2
                        If cont = 1 Then n1 = a
                        If cont = 2 Then
                            If Not IsNull(a) Then n2 = a
                            cont = 0
3:
                            sim = s.remover
                            If sim = "+" Then r = n2 + n1
                            If sim = "-" Then r = n2 - n1
                            If sim = "/" Then r = n2 / n1
                            If sim = "*" Then r = n2 * n1
                             v.meter r
                        End If
                    Wend
                    
                Else
                If l <> "|" Then s.meter l
                End If
            Else
                Var = Var & l
            End If
        Next
        cont = 0
        While (Not s.Vacia)
            cont = cont + 1
            a = v.remover
            If v.Vacia Then cont = 2
            If cont = 1 Then n1 = a
            If cont = 2 Then
                n2 = a
                cont = 0
                sim = s.remover
                If sim = "+" Then r = n2 + n1
                If sim = "-" Then r = n2 - n1
                If sim = "/" Then
                    If n1 > 0 Then
                            r = n2 / n1
                        Else
                            r = 0
                    End If
                End If
                If sim = "*" Then r = n2 * n1
                v.meter r
            End If
        Wend
        Text1.Text = Round(r, 2)
    End If
End Sub
